package com.vitalfit.repository;


import com.vitalfit.model.entity.user.Customer;
import com.vitalfit.model.entity.user.ShopManager;
import com.vitalfit.model.entity.user.Trainer;
import com.vitalfit.model.entity.user.User;
import org.jetbrains.annotations.NotNull;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface UserRepository extends JpaRepository<User, Integer> {

    boolean existsByEmail(String email);
    User findByEmail(String email);

    @Query("SELECT s FROM ShopManager s")
    List<ShopManager> findAllShopManagers();

    @NotNull
    Page<User> findAll(@NotNull Pageable pageable);


    @Query("SELECT c FROM Customer c")
    Page<Customer> findAllCustomers(Pageable pageable);

    @Query("SELECT s FROM ShopManager s")
    Page<ShopManager> findAllShopManagers(Pageable pageable);

    @Query("SELECT t FROM Trainer t")
    Page<Trainer> findAllTrainers(Pageable pageable);

    @Query("SELECT t FROM Trainer t where t.starRating = :starRating")
    Page<Trainer> findAllTrainersByStarRating(int starRating, Pageable pageable);



}
